<template>
  <div class="app-container">
    <!-- 顶部控制台 -->
    <div class="filter-container">
      <el-input class="filter-item" style="width: 160px; margin-left: 0px" size="mini" placeholder="请输入搜索的文案标题" v-model="form.searchTitle"/>
      <el-select class="filter-item" style="width: 120px" size="mini" v-model="form.searchClass" @change="handleSearchClass">
        <el-option v-for="item in pageData.searchClassList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-select class="filter-item" style="width: 120px" size="mini" v-model="form.searchType" :disabled="pageData.searchTypeStatus" @change="handleSearchType">
        <el-option v-for="item in pageData.searchTypeList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-select class="filter-item" style="width: 160px" size="mini" v-model="form.searchProgram" :disabled="pageData.searchProgramStatus" @change="handlePageInit">
        <el-option v-for="item in pageData.searchProgramList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-select class="filter-item" style="width: 120px" size="mini" v-model="form.searchTeacher" :disabled="pageData.searchTeacherStatus" @change="handlePageInit">
        <el-option v-for="item in pageData.searchTeacherList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-select class="filter-item" style="width: 120px" size="mini" v-model="form.searchVipStatus" @change="handlePageInit">
        <el-option v-for="item in pageData.searchVipStatusList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-select class="filter-item" style="width: 120px" size="mini" v-model="form.searchStatus" @change="handlePageInit">
        <el-option v-for="item in pageData.searchStatusList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-button type="primary" size="mini" icon="el-icon-search" @click="handlePageInit">搜索</el-button>
      <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleOpenSavePage">添加</el-button>
      <el-button type="success" size="mini" icon="el-icon-share" @click="handleBatchReleaseData" :disabled="form.selection.length < 1">批量发布</el-button>
      <el-button class="filter-item" type="danger" icon="el-icon-document-copy" size="mini" @click="handleOpenCopyPanel"
                 :disabled="this.form.selection.length < 1">复制到...</el-button>
    </div>
    <!-- 页面数据列表 -->
    <div class="data-table">
      <el-table :data="responseData.tableList"
                border style="width: 100%;"
                v-loading="pageData.loading"
                element-loading-text="拼命加载中"
                element-loading-spinner="el-icon-loading"
                element-loading-background="rgba(0, 0, 0, 0.8)"
                :header-cell-style="{ background: '#545C64', color: '#ffffff' }"
                @selection-change="handleTableSelection">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column fixed="left" prop="articleId" label="文案ID" width="320" align="center"/>
        <el-table-column prop="articleTitle" label="文案标题" width="320" align="center">
          <template slot-scope="scope">
            <span class="link-type" @click="handleOpenEditPage(scope)">{{ scope.row.articleTitle }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="articleClassId" label="所属板块" width="150" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.articleClassId === 2"><el-tag type="primary">视频课堂版块</el-tag></span>
            <span v-if="scope.row.articleClassId === 3"><el-tag type="info">研修直播版块</el-tag></span>
            <span v-if="scope.row.articleClassId === 87"><el-tag type="success">影像大咖</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="articleType" label="所属类型" width="120" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.articleClassId === 87 && scope.row.articleType === 3"><el-tag type="info">影音类型</el-tag></span>
            <span v-if="scope.row.articleClassId !== 87 && scope.row.articleType === 3"><el-tag type="info">视频专区</el-tag></span>
            <span v-if="scope.row.articleType === 4"><el-tag type="danger">精品视频</el-tag></span>
            <span v-if="scope.row.articleType === 5"><el-tag type="warning">红茶坊类型</el-tag></span>
            <span v-if="scope.row.articleType === 6"><el-tag type="success">研修回放类型</el-tag></span>
            <span v-if="scope.row.articleType === 7"><el-tag type="primary">会议现场类型</el-tag></span>
            <span v-if="scope.row.articleType === 8"><el-tag type="info">视频采访类型</el-tag></span>
            <span v-if="scope.row.articleType === 11"><el-tag type="danger">在线课程类型</el-tag></span>
            <span v-if="scope.row.articleType === 23"><el-tag type="danger">精品音频</el-tag></span>
            <span v-if="scope.row.articleType === 87"><el-tag type="danger">影音类型</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="articleIsVip" label="付费状态" width="80" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.articleIsVip === 0"><el-tag type="warning">否</el-tag></span>
            <span v-if="scope.row.articleIsVip === 1"><el-tag type="success">是</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="articleStatus" label="审核状态" width="80" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.articleStatus === 0"><el-tag type="warning">下架</el-tag></span>
            <span v-if="scope.row.articleStatus === 1"><el-tag type="success">发布</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="articleClickCount" label="点击量" width="100" align="center"/>
        <el-table-column prop="articleCreateTime" label="创建时间" width="160" align="center"/>
        <el-table-column prop="articleReleaseTime" label="发布时间" width="160" align="center"/>
        <el-table-column fixed="right" label="操作" width="320" align="center">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="handleOpenAnchorPanel(scope)">随堂小考</el-button>
            <el-button type="primary" size="mini" @click="handleOpenEditPage(scope)">编辑</el-button>
            <el-button v-if="scope.row.articleStatus === 0" size="mini" type="success" @click="handleUpdateDataStatus(scope, 1)">发布</el-button>
            <el-button v-if="scope.row.articleStatus === 1" size="mini" type="warning" @click="handleUpdateDataStatus(scope, 0)">下架</el-button>
            <el-button size="mini" type="danger" @click="handleDeleteData(scope)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--分页器-->
    <div style="margin-top: 20px">
      <div class="block" style="width: 100%; text-align: center">
        <el-pagination
          layout="total, sizes, prev, pager, next, jumper"
          :current-page="form.pageNum"
          :page-size="form.pageSize"
          :total="form.total"
          :page-sizes="[12, 50, 100, 200]"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange">
        </el-pagination>
      </div>
    </div>
    <!-- 复制内容隐藏面板 -->
    <div style="margin-top: 20px;">
      <el-dialog :title="pageData.copyPanelTitle" :visible.sync="pageData.copyPanelStatus" size="tiny" width="80%"
                 :before-close="handleCloseCopyPanel">
        <div style="text-align: center">
          <el-row :gutter="24">
            <!-- 左侧筛选表格 -->
            <el-col :span="12">
              <el-card shadow="always" style="max-height: 640px; overflow-y: auto">
                <el-table :data="responseData.copyList"
                          border style="width: 100%;"
                          ref="multipleTable" tooltip-effect="dark" highlight-current-row>
                  <el-table-column fixed="left" prop="1" label="序号" type="index" width="50" align="center"/>
                  <el-table-column prop="articleTitle" label="标题" width="400" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.articleTitle"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="栏目分类" width="100" align="center">
                    <template slot-scope="scope">
                      <span v-if="scope.row.articleClassId == '2'"><el-tag type="primary">视频课堂</el-tag></span>
                      <span v-if="scope.row.articleClassId == '3'"><el-tag type="info">研修直播</el-tag></span>
                      <span v-if="scope.row.articleClassId == '87'"><el-tag type="success">影像大咖</el-tag></span>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>
            </el-col>
            <!-- 右侧控制菜单 -->
            <el-col :span="12" style="overflow-x: auto">
              <el-card shadow="always" style="max-height: 640px; min-width: 500px;">
                <el-row :gutter="0">
                  <el-col :span="6" style="text-align: left">目标板块分类</el-col>
                  <el-col :span="18" style="text-align: left">目标节目分区</el-col>
                  <el-col :span="6" style="text-align: left; margin-top: 10px">
                    <el-select class="filter-item" style="width: 120px" size="mini" v-model="form.copyType.classType" @change="handleSelectCopyPanelClass">
                      <el-option v-for="item in pageData.copyPanelClassSelectList" :key="item.value" :label="item.label" :value="item.value"/>
                    </el-select>
                  </el-col>
                  <el-col :span="18" style="text-align: left; margin-top: 10px">
                    <el-select class="filter-item" style="width: 80%" size="mini" v-model="form.copyType.classChild" :disabled="pageData.copyPanelClassChildSelectStatus">
                      <el-option v-for="item in pageData.copyPanelClassChildSelectList" :key="item.programId" :label="item.programName" :value="item.programId"/>
                    </el-select>
                  </el-col>
                </el-row>
                <el-row :gutter="0" style="margin-top: 30px">
                  <el-col :span="24" style="text-align: left">目标视频类型</el-col>
                  <el-col :span="24" style="text-align: left; margin-top: 10px">
                    <el-radio-group v-model="form.copyType.type" @change="handleSelectCopyPanelType">
                      <el-radio :label="3" :disabled="pageData.copyTypeSubjectStatus">视频专题</el-radio>
                      <el-radio :label="4" :disabled="pageData.copyTypeBoutiqueStatus">精品课程</el-radio>
                      <el-radio :label="6" :disabled="pageData.copyTypePlayBackStatus">研修回放</el-radio>
                      <el-radio :label="7" :disabled="pageData.copyTypeMeetingStatus">会议现场</el-radio>
                      <el-radio :label="8" :disabled="pageData.copyTypeInterviewStatus">视频采访</el-radio>
                      <el-radio :label="87" :disabled="pageData.copyTypeVideoStatus">影音类型</el-radio>
                    </el-radio-group>
                  </el-col>
                </el-row>
                <el-row :gutter="0" style="margin-top: 30px">
                  <el-col :span="24" style="text-align: left">目标图片设置</el-col>
                  <el-col :span="24">
                    <el-col :span="11" style="text-align: right; margin-right: 20px">
                      <el-upload
                        class="avatar-uploader"
                        action="/yct-cms/OssUpload/OSSUploadFile/"
                        :show-file-list="false"
                        :on-success="handleCopyPanelListImageUploadSuccess">
                        <img v-if="form.copyType.articleImageListImage" :src="form.copyType.articleImageListImage" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon" style="line-height: 175px"></i>
                      </el-upload>
                      <span style="margin-right: 80px">列表图</span>
                    </el-col>
                    <el-col :span="11" style="text-align: left; margin-left: 20px">
                      <el-upload
                        class="avatar-uploader"
                        action="/yct-cms/OssUpload/OSSUploadFile/"
                        :show-file-list="false"
                        :on-success="handleCopyPanelArticleImageUploadSuccess">
                        <img v-if="form.copyType.articleImage" :src="form.copyType.articleImage" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon" style="line-height: 175px"></i>
                      </el-upload>
                      <span style="margin-left: 80px">底层图</span>
                    </el-col>
                  </el-col>
                </el-row>
                <el-row :gutter="0" style="margin-top: 30px">
                  <el-button type="primary" @click.native.prevent="handleCopyPanelSaveButtonClick">复制数据</el-button>
                </el-row>
              </el-card>
            </el-col>
          </el-row>
        </div>
      </el-dialog>
    </div>
    <!-- 随堂检测设置 -->
    <el-dialog title="随堂小考" :visible.sync="pageData.editAnchorPanelStatus" width="80%" style="min-width: 1366px"
               :before-close="handleCloseAnchorPanel">
      <el-card class="box-card">
        <div class="text item">
          <el-table :data="responseData.anchorList"
                    border style="width: 100%;"
                    element-loading-text="拼命加载中"
                    element-loading-spinner="el-icon-loading"
                    element-loading-background="rgba(0, 0, 0, 0.8)"
                    :header-cell-style="{ background: '#545C64', color: '#ffffff' }">
            <el-table-column prop="examQuestionName" label="题目" width="360" align="center">
              <template slot-scope="scope">
                <span class="link-type">{{ scope.row.examQuestionName }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="anchorPopupTime" label="弹出时间" width="120" align="center">
              <template slot-scope="scope">
                <span class="link-type">{{ scope.row.anchorPopupTime }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="anchorStatus" label="弹出类型" width="240" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.anchorStatus == 1"><el-tag type="info">仅一次</el-tag></span>
                <span v-if="scope.row.anchorStatus == 2"><el-tag type="success">一直弹出</el-tag></span>
              </template>
            </el-table-column>
            <el-table-column prop="anchorId" label="锚点ID" width="320" align="center"/>
            <el-table-column prop="examQuestionId" label="问题ID" width="320" align="center"/>
            <el-table-column fixed="right" label="操作" width="180" align="center">
              <template slot-scope="scope">
                <el-button type="primary" size="mini" @click="handleOpenQuestionUpdatePanel(scope)">修改题目</el-button>
                <el-button type="danger" size="mini" @click="handleDeleteArticleAnchor(scope)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-card>
      <el-card class="box-card">
        <el-form :model="form.anchorData" label-width="100px" ref="form.anchorData">
          <div class="text_item">
            <el-form-item prop="onlineAnchorStatus" label="弹出类型">
              <el-radio v-model="form.anchorData.anchorStatus" :label="1">仅一次</el-radio>
              <el-radio v-model="form.anchorData.anchorStatus" :label="2">一直弹出</el-radio>
            </el-form-item>
            <el-form-item prop="onlinePopupTime" label="弹出时间(秒)">
              <el-input v-model="form.anchorData.anchorPopupTime" class="filter-item" auto-complete="off"/>
            </el-form-item>
            <el-form-item prop="onlineAnchorId" label="检测内容">
              <el-select v-model="form.anchorData.questionId" filterable remote reserve-keyword placeholder="请输入关键词" :remote-method="handleRemoteQuestionData">
                <el-option
                  v-for="data in responseData.questionList"
                  :key="data.value"
                  :label="data.label"
                  :value="data.value">
                  <span class="title_left">{{ data.label }}</span>
                  <span class="title_right">{{ data.typeLabel }}</span>
                </el-option>
              </el-select>
            </el-form-item>
            <div style="margin-top: 20px">
              <el-button type="primary" @click.native.prevent="handleSaveArticleAnchorData">保存锚点</el-button>
            </div>
          </div>
        </el-form>
      </el-card>
    </el-dialog>
    <!--题目修改详情页-->
    <el-dialog title="随堂小考" :visible.sync="pageData.editAnchorQuestionPanelStatus" width="80%" style="min-width: 1366px"
               :before-close="handleCloseQuestionUpdatePanel">
      <el-card class="box-card">
        <el-form :model="form.anchorQuestionData" label-width="100px" ref="form.anchorData">
          <div class="text_item">
            <el-form-item prop="onlineAnchorStatus" label="弹出类型">
              <el-radio v-model="form.anchorQuestionData.anchorStatus" :label="1">仅一次</el-radio>
              <el-radio v-model="form.anchorQuestionData.anchorStatus" :label="2">一直弹出</el-radio>
            </el-form-item>
            <el-form-item prop="onlinePopupTime" label="弹出时间(秒)">
              <el-input v-model="form.anchorQuestionData.anchorPopupTime" class="filter-item" auto-complete="off"/>
            </el-form-item>
            <el-form-item prop="onlineAnchorId" label="检测内容">
              <el-select v-model="form.anchorQuestionData.questionId" filterable remote reserve-keyword placeholder="请输入关键词" :remote-method="handleRemoteQuestionData">
                <el-option
                  v-for="data in responseData.questionList"
                  :key="data.value"
                  :label="data.label"
                  :value="data.value">
                  <span class="title_left">{{ data.label }}</span>
                  <span class="title_right">{{ data.typeLabel }}</span>
                </el-option>
              </el-select>
            </el-form-item>
            <div style="margin-top: 20px">
              <el-button type="primary" @click.native.prevent="handleUpdateArticleAnchorData">更新锚点</el-button>
            </div>
          </div>
        </el-form>
      </el-card>
    </el-dialog>
  </div>
</template>

<script>
  // 组件引入
  // 方法工具引入
  import { PermissionsToDetectFormUser } from '@/utils/PermissionsDetect';
  import { getPermission } from '@/utils/UserCookies';
  // 接口引入
  import { loadCmsProgramSearchList,loadCmsTeacherSearchList,loadCmsArticleList,batchReleaseCmsArticleData,deleteCmsArticleData,loadCmsProgramList,saveCmsArticleCopyData,
    loadCmsArticleAnchorList,saveCmsArticleAnchorData,updateCmsArticleAnchorData,deleteCmsArticleAnchorData} from "@/api/content";
  import { loadCmsQuestionDataList } from "@/api/study";
  export default {
    name: "video",
    //import引入的组件需要注入到对象中才能使用
    components: {},
    data (){
      return {
        pageData:{
          searchClassList: [
            {label: "栏目分类", value: -1},
            {label: "视频课堂", value: 2},
            {label: "研修直播", value: 3},
            {label: "影像大咖", value: 87}
          ],// 一级分类预设信息
          searchTypeStatus: true,// 二级分类是否可选标识
          VideoTypeSelectList: [
            {value: '', label: '板块分类'}
          ],
          VideoTypeSelectList1:[
            {value: '', label: '板块分类'},{value: '3', label: '视频专区'}, {value: '4', label: '精品视频'}, {value: '5', label: '红茶访'}
          ],
          VideoTypeSelectList2:[
            {value: '', label: '板块分类'},{value: '6', label: '研修回放'}, {value: '7', label: '会议现场'}, {value: '8', label: '视频采访'}
          ],
          VideoTypeSelectList3:[
            {value: '', label: '板块分类'},{value: '3', label: '影音类型'}
          ],
          searchTypeList: [
            {label: "板块分类", value: -1},
          ],// 类型筛选预设值
          searchTypeList1: [
            {label: "板块分类", value: -1},
            {label: "视频专区", value: 3},
            {label: "精品视频", value: 4},
            {label: "红茶访", value: 5},
          ],
          searchTypeList2: [
            {label: "板块分类", value: -1},
            {label: "研修回放", value: 6},
            {label: "会议现场", value: 7},
            {label: "视频采访", value: 8},
          ],
          searchTypeList3: [
            {label: "板块分类", value: -1},
            {label: "视频采访", value: 8},
            {label: "影音类型", value: 87},
          ],
          searchProgramStatus: true,
          searchProgramList: [
            {label: "节目分类", value: -1},
          ],// 节目筛选项
          searchTeacherStatus: true,
          searchTeacherList: [
            {label: "讲师分类", value: -1},
          ],// 讲师筛选项
          searchVipStatusList: [
            {label: "付费状态", value: -1},
            {label: "免费", value: 0},
            {label: "付费", value: 1}
          ],// 付费状态预设项
          searchStatusList: [
            {label: "发布状态", value: -1},
            {label: "下架", value: 0},
            {label: "发布", value: 1}
          ],// 发布状态预设项
          loading: false,// 登录LOAD图
          copyPanelStatus: false,// 内容复制面板状态
          copyPanelTitle: "",// 内容复制面板标题
          copyPanelClassSelectList:[
            {value: 2, label: '视频课堂'},
            {value: 3, label: '研修直播'},
            {value: 87, label: '影像大咖'}
          ],// 内容复制面板，可复制板块筛选项
          copyPanelClassChildSelectStatus: true,
          copyTypeSelectStatus: true,
          copyTypeSubjectStatus: false,
          copyTypeBoutiqueStatus: false,
          copyTypePlayBackStatus: true,
          copyTypeMeetingStatus: true,
          copyTypeInterviewStatus: true,
          copyTypeVideoStatus: true,// 视频复制面板子集筛选项可用状态
          copyPanelClassChildSelectList:[{value: '', label: '板块分类'}],
          editAnchorPanelStatus: false,// 随堂检测设置面板
          editAnchorQuestionPanelStatus: false,// 随堂小考题目修改面板
        },// 页面配置数据
        form:{
          queryScope: 3,
          searchTitle: "",
          searchClass: -1,
          searchType: -1,
          searchProgram: -1,
          searchTeacher: -1,
          searchVipStatus: -1,
          searchStatus: -1,
          pageNum: 1,// 表单--页码
          pageSize: 12,// 表单--页面
          total: 0,// 表单--总量
          selection: [],// 多选的内容
          copyType:{
            classType: 2,
            classChild: "",
            type: 3,
            articleImageListImage: "",// 列表展示图
            articleImage: ""// 播放页展示图
          },// 一键复制的拷贝表单
          anchorData: {
            articleId: "",
            questionId: "",
            anchorStatus: 2,
            anchorPopupTime: "0",
            articleStudyTime: 0
          },// 随堂检测表单
          anchorQuestionData: {
            id: "",
            anchorStatus: 2,
            anchorPopupTime: 0,
            questionId: ""
          },// 随堂小考修改题目表单
        },// 页面表单
        formRules: {
        },// 表单验证
        responseData: {
          tableList: [],// 页面表格数据
          copyList: [],// 内容复制面板列表
          anchorList: [],// 视频关联的随堂小考列表
          questionList: [],// 随堂小考搜索的题目列表
        },// 接口响应数据
      }
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
      // 事件函数
      handlePageInit(){
        this.form.pageNum = 1;
        this.pageData.loading = true;// 创建加载窗口
        this.loadCmsArticleList();// 读取路由角色列表
      },// 页面初始化事件
      handleCurrentChange(val){
        this.form.pageNum = val;// 更换页码
        this.pageData.loading = true;// 创建加载窗口
        this.loadCmsArticleList();// 读取路由角色列表
      },// 页码切换事件
      handleSizeChange(val){
        this.form.pageSize = val;// 更换页面大小
        this.pageData.loading = true;// 创建加载窗口
        this.loadCmsArticleList();// 读取路由角色列表
      },// 页面size切换事件
      handleTableSelection(val){
        let list = [];// 初始化多选数组
        for (let i=0; i<val.length; i++){
          list.push(val[i].articleId);
        }// 遍历多选的列表，将ID拼入数组中
        this.form.selection = list;// 进行多选值的切换
      },// 表格多选事件
      handleSearchClass(){
        // 进行分类数据的判定
        if (this.form.searchClass !== -1){
          this.pageData.searchTypeStatus = false;
          this.form.searchType = -1;
          if (this.form.searchClass === 2){
            this.pageData.searchTypeList = this.pageData.searchTypeList1;
          } else if (this.form.searchClass === 3){
            this.pageData.searchTypeList = this.pageData.searchTypeList2;
          } else if (this.form.searchClass === 87) {
            this.pageData.searchTypeList = this.pageData.searchTypeList3;
            this.loadCmsProgramSearchList(true);
            this.form.searchProgram = -1;
            this.pageData.searchProgramStatus = false;// 打开三级筛选项可用状态
            // 搜索对应可用讲师
            this.loadCmsTeacherSearchList();
            this.form.searchTeacher = -1;
            this.pageData.searchTeacherStatus = false;// 打开三级筛选项可用状态
          }
        } else {
          this.pageData.searchTypeStatus = true;
          this.form.searchType = -1;
        }
        this.handlePageInit();
      },// 一级分类筛选事件
      handleSearchType(){
        if (this.form.searchClass == 2 && (this.form.searchType == 3 || this.form.searchType == 4)){
          // 搜索对应可用节目
          this.loadCmsProgramSearchList();
          this.form.searchProgram = -1;
          this.pageData.searchProgramStatus = false;// 打开三级筛选项可用状态
          // 搜索对应可用讲师
          this.loadCmsTeacherSearchList();
          this.form.searchTeacher = -1;
          this.pageData.searchTeacherStatus = false;// 打开三级筛选项可用状态
        } else {
          this.form.searchProgram = -1;
          this.pageData.searchProgramStatus = true;// 打开三级筛选项可用状态
          this.form.searchTeacher = -1;
          this.pageData.searchTeacherStatus = true;// 打开三级筛选项可用状态
          this.handlePageInit();
        }
      },// 二级分类筛选事件
      handleOpenSavePage(){
        if (PermissionsToDetectFormUser(getPermission(), "400001")){
          this.$jump.push({path: "/content/articleSave", query: {routerType: 3}});
        }  else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 打开新增页面
      handleOpenEditPage(scope){
        if (PermissionsToDetectFormUser(getPermission(), "400003")){
          let routeUrl = this.$router.resolve({
            path: "/content/articleEdit",
            query: {articleId: scope.row.articleId, routerType: 3}
          });
          window.open(routeUrl.href, '_blank');// 使用开启新窗口跳转
        }  else {
          // 当前权限不足，不执行操作，给与相应提示
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 打开修改页面
      handleBatchReleaseData(){
        if (PermissionsToDetectFormUser(getPermission(), "400005")){
          this.$confirm("是否发布当前所选数据?", "提示", {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let param = {
              articleId: this.form.selection.toString(),
              articleStatus: 1
            };
            this.batchReleaseCmsArticleData(param);
          }).catch(close => {
            console.log(close);
            this.$message.info("已取消操作");
          });
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 批量发布数据
      handleOpenCopyPanel(){
        // 根据筛选项进行复制数据获取
        let param = {articles: this.form.selection.toString()};
        this.loadCmsArticleListById(param);
        // 打开内容复制面板
        this.pageData.copyPanelStatus = true;
        this.pageData.copyPanelTitle = "复制内容设置（本次共需复制"+this.form.selection.length+"条数据至）";
      },// 打开课程复制面板
      handleCloseCopyPanel(){
        this.$confirm("确认关闭？").then(response => {
          // 打开面板
          this.pageData.copyPanelStatus = false;
        }).catch(err => {
          console.log(err);
        });
      },// 关闭课程复制面板
      handleSelectCopyPanelClass(){
        if (this.form.copyType.classType !== ""){
          if (this.form.copyType.classType == 2){// 视频课堂
            this.pageData.copyPanelClassChildSelectStatus = false;// 子集选项
            this.pageData.copyTypeSubjectStatus = false;//视频专题
            this.pageData.copyTypeBoutiqueStatus = false;//精品课程
            this.pageData.copyTypePlayBackStatus = true;//研修回放
            this.pageData.copyTypeMeetingStatus = true;//会议现场
            this.pageData.copyTypeInterviewStatus = true;//视频采访
            this.pageData.copyTypeVideoStatus = true;//影音类型
            this.form.copyType.type = 3;// 设置表单类型
            let param = {searchType: 3};
            this.loadCmsProgramList(param);
          } else if (this.form.copyType.classType == 3) {
            this.pageData.copyPanelClassChildSelectStatus = true;
            this.pageData.copyTypeSubjectStatus = true;//视频专题
            this.pageData.copyTypeBoutiqueStatus = true;//精品课程
            this.pageData.copyTypePlayBackStatus = false;//研修回放
            this.pageData.copyTypeMeetingStatus = false;//会议现场
            this.pageData.copyTypeInterviewStatus = false;//视频采访
            this.pageData.copyTypeVideoStatus = true;//影音类型
            this.form.copyType.type = 6;// 设置表单类型
            this.form.copyType.classChild = "";
          } else if (this.form.copyType.classType == 87){
            this.pageData.copyPanelClassChildSelectStatus = true;
            this.pageData.copyTypeSubjectStatus = true;//视频专题
            this.pageData.copyTypeBoutiqueStatus = true;//精品课程
            this.pageData.copyTypePlayBackStatus = true;//研修回放
            this.pageData.copyTypeMeetingStatus = true;//会议现场
            this.pageData.copyTypeInterviewStatus = true;//视频采访
            this.pageData.copyTypeVideoStatus = false;//影音类型
            this.form.copyType.type = 87;
            this.form.copyType.classChild = "";
          }
        } else {
          this.pageData.copyPanelClassChildSelectStatus = true;
          this.form.copyType.classChild = "";
        }
      },// 课程复制面板切换目标板块类型
      handleSelectCopyPanelType(){
        if (this.form.copyType.classType === 2){
          this.pageData.copyPanelClassChildSelectStatus = false;
          this.form.copyType.classChild = "";
          let param = {
            searchType: this.form.copyType.type
          };
          this.loadCmsProgramList(param);
        } else {
          this.pageData.copyPanelClassChildSelectStatus = true;
          this.form.copyType.classChild = '';
        }
      },// 课程复制面板切换目标类型
      handleCopyPanelListImageUploadSuccess(response, file){
        this.form.copyType.articleImageListImage = response.data;
      },// 复制面板列表图上传成功
      handleCopyPanelArticleImageUploadSuccess(response, file){
        this.form.copyType.articleImage = response.data;
      },// 复制面板底层图上传成功
      handleCopyPanelSaveButtonClick(){
        if (this.form.copyType.classType == 2 && this.form.copyType.classChild == ""){
          this.$message.warning("请选择对应的目标节目分区");
        } else {
          this.$confirm('当前操作会将当前数据同步复制到所选模块中, 请核对后继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let param = {
              copyData: this.responseData.copyList,
              classType: this.form.copyType.classType,
              classChild: this.form.copyType.classChild,
              type: this.form.copyType.type,
              articleImageListImage: this.form.copyType.articleImageListImage,
              articleImage: this.form.copyType.articleImage
            };
            this.saveCmsArticleCopyData(param);

          }).catch(close => {
            console.log(close);
            this.$message.info("已取消操作");
          });
        }
      },// 课程复制按钮点击事件
      handleOpenAnchorPanel(scope){
        if (scope.row.articleClassId != 87){
          this.$message.warning("当前数据不是易考通课程，无需设置随堂检测");
        } else {
          // 获取当前视频所关联的随堂检测列表
          let param = {articleId: scope.row.articleId};
          this.loadCmsArticleAnchorList(param);
          // 打开随堂检测设置面板
          this.pageData.editAnchorPanelStatus = true;
          this.form.anchorData = {
            articleId: scope.row.articleId,
            questionId: "",
            anchorStatus: 2,
            anchorPopupTime: "0",
            articleStudyTime: scope.row.articleStudyTime
          }
        }
      },// 打开随堂小考设置隐藏面板
      handleCloseAnchorPanel(){
        this.$confirm("确认关闭？").then(response => {
          // 打开随堂检测设置面板
          this.pageData.editAnchorPanelStatus = false;
          this.form.anchorData = {
            articleId: "",
            questionId: "",
            anchorStatus: 2,
            anchorPopupTime: "0",
          };
          this.responseData.anchorList = [];
        }).catch(err => {
          console.log(err);
        });
      },// 关闭随堂检测设置面板
      handleRemoteQuestionData(query){
        if (query !== ''){
          let param = { searchTitle: query };
          this.loadCmsQuestionDataList(param);
        } else {
          this.responseData.questionList = [];
        }
      },// 随堂小考设置面板搜索题目
      handleSaveArticleAnchorData(){
        if (PermissionsToDetectFormUser(getPermission(), "420009")){
          if (parseInt(this.form.anchorData.anchorPopupTime) > parseInt(this.form.anchorData.articleStudyTime)){
            // 弹出时间大于视频的学习时长
            this.$message.warning("随堂小考弹出时间异常，请重新设置");
            return;
          }
          if (this.form.anchorData.questionId == ""){// 未选择锚点则不保存数据
            // 打开随堂检测设置面板
            this.pageData.editAnchorPanelStatus = false;
            this.form.anchorData = {
              articleId: "",
              questionId: "",
              anchorStatus: 2,
              anchorPopupTime: "0",
            }
          } else {
            this.$confirm('是否保存该锚点数据, 请核对后继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.saveCmsArticleAnchorData();
            }).catch(close => {
              console.log(close);
              this.$message.info("已取消操作");
            });
          }
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 保存随堂小考
      handleOpenQuestionUpdatePanel(scope){
        if (PermissionsToDetectFormUser(getPermission(), "420009")){
          this.form.anchorQuestionData.id = scope.row.id;
          this.form.anchorQuestionData.anchorStatus = scope.row.anchorStatus;
          this.form.anchorQuestionData.anchorPopupTime = scope.row.anchorPopupTime;
          this.form.anchorQuestionData.questionId = scope.row.examQuestionId;
          this.pageData.editAnchorQuestionPanelStatus = true;
          let array = [];
          array.push({
            label: scope.row.examQuestionName,
            value: scope.row.examQuestionId,
          });
          this.responseData.questionList = array;
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 打开题目修改面板
      handleCloseQuestionUpdatePanel(){
        this.$confirm("确认关闭？").then(response => {
          // 打开随堂检测设置面板
          this.pageData.editAnchorQuestionPanelStatus = false;
          this.form.anchorQuestionData.id = "";
          this.form.anchorQuestionData.anchorStatus = 2;
          this.form.anchorQuestionData.anchorPopupTime = 0;
          this.form.anchorQuestionData.questionId = "";
          this.responseData.questionList = [];
        }).catch(err => {
          console.log(err);
        });
      },// 关闭题目修改面板
      handleUpdateArticleAnchorData(){
        if (PermissionsToDetectFormUser(getPermission(), "420009")){
          this.$confirm('是否保存该锚点数据, 请核对后继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let prams = {
              id: this.form.anchorQuestionData.id,
              anchorStatus: this.form.anchorQuestionData.anchorStatus,
              anchorPopupTime: this.form.anchorQuestionData.anchorPopupTime,
              questionId: this.form.anchorQuestionData.questionId,
            };
            this.updateCmsArticleAnchorData(prams);
            // 打开随堂检测设置面板
            this.pageData.editAnchorQuestionPanelStatus = false;
            this.form.anchorQuestionData.id = "";
            this.form.anchorQuestionData.anchorStatus = 2;
            this.form.anchorQuestionData.anchorPopupTime = 0;
            this.form.anchorQuestionData.questionId = "";
            this.responseData.questionList = [];
          }).catch(close => {
            console.log(close);
            this.$message.info("已取消操作");
          });
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 更新题目设置
      handleDeleteArticleAnchor(scope){
        if (PermissionsToDetectFormUser(getPermission(), "420010")){
          this.$confirm('是否删除该锚点数据, 请核对后继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let prams = {id: scope.row.id};
            this.deleteCmsArticleAnchorData(prams);
          }).catch(close => {
            console.log(close);
            this.$message.info("已取消操作");
          });
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 删除随堂小考
      handleUpdateDataStatus(scope, status){
        if (PermissionsToDetectFormUser(getPermission(), "460005")){
          this.$confirm("是否更改当前所选数据的发布状态?", "提示", {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let param = {
              articleId: scope.row.articleId,
              articleStatus: status
            };
            this.batchReleaseCmsArticleData(param);
          }).catch(close => {
            console.log(close);
            this.$message.info("已取消操作");
          });
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 更改内容发布状态
      handleDeleteData(scope){
        if (PermissionsToDetectFormUser(getPermission(), "400002")){
          // 付费内容--并且点击量不为0的内容无法删除
          if (scope.row.articleIsVip === 1 || parseInt(scope.row.articleClickCount) > 0 || scope.row.articleStatus === 1){
            this.$message.info("付费、发布、点击量大于0的内容暂不支持自动删除，请联系管理员");
          } else {
            // 进行文案内容的删除
            this.$confirm('是否删除当前所选数据?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              // 拼接访问参数
              let prams = {articleId: scope.row.articleId,};
              // 进行数据请求
              this.deleteCmsArticleData(prams);
            }).catch(cancel => {
              console.log(cancel);
              this.$message.info("已取消操作");
            });
          }
        }  else {
          // 当前权限不足，不执行操作，给与相应提示
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 删除内容
      // 接口
      loadCmsProgramSearchList(temp){
        let param;
        if (temp){
          param = {searchType: 7};
        } else {
          param = {searchType: this.form.searchType};
        }
        loadCmsProgramSearchList(param).then(response => {
          if (response.code === "200"){
            this.pageData.searchProgramList = response.data;
            this.pageData.searchProgramList.unshift({label: "节目分类", value: -1});
          } else {
            this.$message.warning(response.message);
          }
        }).catch( error =>{
          console.log(error);
          this.$message.error(error);
        })
      },// 根据类型获取节目列表筛选项
      loadCmsTeacherSearchList(){
        loadCmsTeacherSearchList().then(response => {
          if (response.code === "200"){
            this.pageData.searchTeacherList = response.data;
            this.pageData.searchTeacherList.unshift({label: "讲师分类", value: -1});
          } else {
            this.$message.warning(response.message);
          }
        }).catch( error =>{
          console.log(error);
          this.$message.error(error);
        })
      },// 获取讲师筛选项
      loadCmsArticleList(){
        loadCmsArticleList(this.form).then(response => {
          if (response.code === "200"){
            this.pageData.loading = false;
            this.responseData.tableList = response.data.list;
            this.form.total = response.data.total;
          } else {
            this.$message.warning(response.message);
          }
        }).catch( error =>{
          console.log(error);
          this.$message.error(error);
        })
      },// 获取文章列表数据
      batchReleaseCmsArticleData(param){
        batchReleaseCmsArticleData(param).then(response => {
          if (response.code === "200"){
            this.$message.success(param.articleStatus === 1 ? "发布成功" : "下架成功");
            this.handlePageInit();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(close => {
          console.log(close);
        });
      },// 批量发布内容
      loadCmsArticleListById(param){
        loadCmsArticleList(param).then(response =>{
          if (response.code === "200"){
            this.responseData.copyList = response.data.list;
            this.handleSelectCopyPanelClass();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        });
      },// 获取内容复制面板列表
      loadCmsProgramList(param){
        loadCmsProgramList(param).then(response =>{
          if (response.code === "200"){
            this.pageData.copyPanelClassChildSelectList = response.data.list;
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      },// 获取可用节目列表
      saveCmsArticleCopyData(param){
        saveCmsArticleCopyData(param).then(response =>{
          if (response.code === "200"){
            this.$message.success("内容复制成功");
            this.pageData.copyPanelStatus = false;
            this.handlePageInit();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        });
      },// 保存课程复制数据
      loadCmsArticleAnchorList(param){
        loadCmsArticleAnchorList(param).then(response => {
          if (response.code === "200"){
            this.responseData.anchorList = response.data;
          } else {
            this.$message.warning(response.message);
          }
        }).catch(close => {
          console.log(close);
        });
      },// 获取当前内容关联的锚点列表
      loadCmsQuestionDataList(param){
        loadCmsQuestionDataList(param).then(response => {
          if (response.code === "200"){
            this.responseData.questionList = response.data;
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      },// 搜索可用随堂小考题目
      saveCmsArticleAnchorData(){
        saveCmsArticleAnchorData(this.form.anchorData).then(response => {
          if (response.code === "200"){
            this.$message.success('锚点保存成功');
            // 获取当前视频所关联的随堂检测列表
            let param = {articleId: this.form.anchorData.articleId};
            this.loadCmsArticleAnchorList(param);
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      },// 保存视频锚点数据
      updateCmsArticleAnchorData(param){
        updateCmsArticleAnchorData(param).then(response => {
          if (response.code === "200"){
            this.$message.success('锚点更新成功');
            // 获取当前视频所关联的随堂检测列表
            let param = {articleId: this.form.anchorData.articleId};
            this.loadCmsArticleAnchorList(param);
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      },// 更新视频锚点数据
      deleteCmsArticleAnchorData(param){
        deleteCmsArticleAnchorData(param).then(response => {
          if (response.code === "200"){
            this.$message.success('锚点删除成功');
            // 获取当前视频所关联的随堂检测列表
            let param = {articleId: this.form.anchorData.articleId};
            this.loadCmsArticleAnchorList(param);
            // 打开随堂检测设置面板
            this.pageData.editAnchorPanelStatus = true;
            this.form.anchorData.questionId = "";
            this.form.anchorData.anchorStatus = 2;
            this.form.anchorData.anchorPopupTime = "0";
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      },// 删除视频锚点数据
      deleteCmsArticleData(param){
        deleteCmsArticleData(param).then(response => {
          if (response.code === "200"){
            this.$message.success("删除成功");
            this.handlePageInit();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(close => {
          console.log(close);
        });
      }// 删除文章数据
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created: function(){
      let _this = this;
      document.onkeydown = function(e) {
        if (!_this.pageData.loading) {
          let key = window.event.keyCode;
          if (key === 13) {
            _this.handlePageInit(); //此方法是当按下enter键后要做的动作。
          }
        }
      };
      setTimeout(function () {
        _this.handlePageInit();
      }, 800);
    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {},
    beforeCreate() {}, //生命周期 - 创建之前
    beforeMount() {}, //生命周期 - 挂载之前
    beforeUpdate() {}, //生命周期 - 更新之前
    updated() {}, //生命周期 - 更新之后
    beforeDestroy() {}, //生命周期 - 销毁之前
    destroyed() {}, //生命周期 - 销毁完成
    activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .title_left{
    float: left;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 630px;
  }
  .title_right{
    float: right;
    color: #8492a6;
    font-size: 13px;
    width: 80px;
  }
</style>
